<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>实验四第(2)问</title>
		<link rel="stylesheet" href="./css/demo-04.css">
	</head>
	<style type="text/css">
	        table
	        {
	            border-collapse: collapse; /*相邻边被合并;separate: 边框独立*/
	            border: none;
	            width: 820px;
	        }
	        td
	        {
	            border: solid #CCC 1px;
	        }
	    </style>
	<body>
		<h2>实验四第(2)问，使用js事件对于条目的检查，点击下面连接跳转到下一问</h2>
		<a href="index.html">实验四第(1)问</a><br>
		<a href="index_03.html">实验四第(3)问</a>
		<br><br><hr><br>
		<!-- <h1 align="center">每天进步一点点</h1> -->
		<div >
			<form name="registerForm">
				<table class="all">
					<tr class="zero">
						<td>
							<h2 align="center">每天进步一点点</h2>
						</td>
						<td>
							<h2 align="center">收获多一点点</h2>
						</td>
					</tr>
					<!-- 第一行 -->
					<tr class="one">
						<td class="one-01">用户名</td>
						<td class="one-02">
							<input type="text" name="name" placeholder="请输入用户名"/>
						</td>
					</tr>
					<!-- 第二行 -->
					<tr class="two">
						<td class="two-01">密码</td>
						<td class="two-02">
							<input type="password" name="pwd" placeholder="请输入密码"/>
						</td>
					</tr>
					<!-- 第三行 -->
					<tr class="three">
						<td class="three-01">确认密码</td>
						<td class="three-02">
							<input type="password" name="repwd" placeholder="请输入确认密码" />
						</td>
					</tr>
					<tr class="four">
						<td></td>
						<td class="four-01">
							<input type="submit" onclick="checkForm()" value="免费注册" />
						</td>
					</tr>
				</table>
			</form>
		</div>
	
		<script type="text/javascript">
		        function checkForm() {
		            var name = registerForm.name.value;
		            var pwd = registerForm.pwd.value;
		            var repwd = registerForm.repwd.value;

		            //alert(name + pwd + repwd);
		            if (name == "" || name == null) {
		                alert("注册失败！用户名不能为空");
		                registerForm.name.focus();
		                return false;
		            } else if (pwd == "" || pwd == null) {
		                alert("注册失败！密码不能为空");
		                registerForm.pwd.focus();
		                return false;
		            } else if (repwd == "" || repwd == null) {
		                alert("注册失败！重复密码不能为空");
		                registerForm.repwd.focus();
		                return false;
		            }else if(pwd!=repwd){
		                alert("注册失败！两次密码输入不一致，请重新输入!");
		                registerForm.repwd.focus();
		                return false;
		            }
		            alert('注册成功！');
		            return true;
		        }
		    </script>
	</body>
</html>
